package com.meiyou.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.meiyou.utils.Msg;
import com.qq.connect.QQConnectException;
import com.qq.connect.api.OpenID;
import com.qq.connect.api.qzone.UserInfo;
import com.qq.connect.javabeans.AccessToken;
import com.qq.connect.javabeans.qzone.UserInfoBean;
import com.qq.connect.oauth.Oauth;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@Api(value = "QQLogin")
public class QQController {
	
	
	
	
	@RequestMapping("")
	public @ResponseBody Msg qqLogin(String code,HttpServletRequest req){
		return null;
	}
	
	
	/*
	 * @RequestMapping("qqLogin")
	 * 
	 * @ResponseBody
	 * 
	 * @ApiOperation(value = "qq登录") public ModelAndView qqLogin(HttpServletRequest
	 * request, HttpServletResponse response) throws Exception {
	 * response.setContentType("text/html;charset=utf-8"); try {
	 * response.sendRedirect(new Oauth().getAuthorizeURL(request)); } catch
	 * (QQConnectException e) { e.printStackTrace(); }
	 * 
	 * return null; }
	 * 
	 * 
	 * 
	 * @RequestMapping("afterLogin") public ModelAndView
	 * afterLogin(HttpServletRequest request, HttpServletResponse response) throws
	 * Exception {
	 * 
	 * try { AccessToken accessTokenObj = (new
	 * Oauth()).getAccessTokenByRequest(request); String accessToken = null, openID
	 * = null; long tokenExpireIn = 0L; if
	 * (accessTokenObj.getAccessToken().equals("")) { System.out.print("没有获取到响应参数");
	 * }else{ accessToken = accessTokenObj.getAccessToken(); tokenExpireIn =
	 * accessTokenObj.getExpireIn(); OpenID openIDObj = new OpenID(accessToken);
	 * openID = openIDObj.getUserOpenID(); UserInfo qzoneUserInfo = new
	 * UserInfo(accessToken, openID); UserInfoBean userInfoBean =
	 * qzoneUserInfo.getUserInfo(); String name = userInfoBean.getNickname();
	 * System.out.println("欢迎你，" + name + "!"); } }catch(Exception e){
	 * e.printStackTrace(); } return null; }
	 */
}
